package flib;

import importExport.SVGLoader;

import java.awt.Color;

import org.w3c.dom.Element;

import processing.core.PGraphics;

public class WallType {
	//(String label,boolean transparent,boolean permeable,boolean fix,boolean isolating,boolean supporting,Color color)
	public static WallType typeWall=initType("wall",false,false,true,true,true, Color.BLACK);
	public static WallType typeWallGlass=initType("wall-glass",true,false,true,true,false, Color.BLACK);
	public static WallType typeWallCloset=initType();
	public static WallType typeWindow=initType("window",true,false,true,true,false, Color.BLACK);
	public static WallType typeBalustrade=initType("wall-balustrade",true,false,true,false,false, Color.BLACK);
	public static WallType typeDoor=initType("door",false,true,true,true,false, Color.BLACK);
	public static WallType typeDoorEntrance=initType("door-entrance",false,true,true,true,false, Color.BLACK);
	public static WallType typeDoorElevator=initType();
	public static WallType typeDoorSliding=initType();
	public static WallType typeDoorGarage=initType();
	public static WallType typeWallHelp=initType("wall-help",true,true,true,false,false,true,Color.BLACK);
	public static WallType typeStairStart=initType("stair-top",true,true,true,false,false,true,Color.BLACK);
	public static WallType typeStairEnd=initType("stair-down",true,true,true,false,false,true,Color.BLACK);
	public static WallType typeStairSegment=initType("stair-segment",true,true,true,false,false,true,Color.BLACK);
	


	public static WallType[] wallTypes=new WallType[]{
		typeWall,
		typeWallGlass,
		typeWallCloset,
		typeWallHelp,
		typeWindow,
		typeBalustrade,
		typeDoor,
		typeDoorEntrance,
		typeDoorElevator,
		typeDoorSliding,
		typeDoorGarage,
		typeStairStart,
		typeStairEnd,
		typeStairSegment
	};
	
	public static WallType getTypeByLabel(String label){
		for (int i=0;i<wallTypes.length;i++){
			WallType wType=wallTypes[i];
			//System.out.println("label: "+label);
			if (label.equals(wType.label))return wType; 
		}
		return null;
	}
public String label;
public Color color;
public boolean transparent;
public boolean permeable;
public boolean fix;
public boolean isolating;
public boolean supporting;
public boolean helper;
public WallType(){
	
}


public void load(Element element){
	label=element.getAttribute("label");
	transparent=Boolean.valueOf(element.getAttribute("transparent"));
	fix=Boolean.valueOf(element.getAttribute("fix"));
	isolating=Boolean.valueOf(element.getAttribute("isolating"));
	supporting=Boolean.valueOf(element.getAttribute("supporting"));
	permeable=Boolean.valueOf(element.getAttribute("permeable"));
	helper=Boolean.valueOf(element.getAttribute("helper"));
	color=SVGLoader.getColorFromRGBString(element.getAttribute("color"));
}
public static WallType initType(){
	return initType("wall",false,false,true,true,true, Color.BLACK);
	
}
public static WallType initType(String label,boolean transparent,boolean permeable,boolean fix,boolean isolating,boolean supporting,Color color){
	WallType edgeType=new WallType();
	edgeType.label=label;
	edgeType.transparent=transparent;
	edgeType.permeable=permeable;
	edgeType.fix=fix;
	edgeType.isolating=isolating;
	edgeType.supporting=supporting;
	return edgeType;
}
public static WallType initType(String label,boolean transparent,boolean permeable,boolean fix,boolean isolating,boolean supporting,boolean helper,Color color){
	WallType edgeType=new WallType();
	edgeType.label=label;
	edgeType.transparent=transparent;
	edgeType.permeable=permeable;
	edgeType.fix=fix;
	edgeType.isolating=isolating;
	edgeType.supporting=supporting;
	edgeType.helper=helper;
	return edgeType;
}
public boolean isTransparent() {
	return transparent;
}

public void setTransparent(boolean transparent) {
	this.transparent = transparent;
}

public boolean isCut(){
	if (label.contains("stair")||label.contains("balustrade"))return false;
	return true;
}
public boolean isPermeable() {
	return permeable;
}

public void setPermeable(boolean permeable) {
	this.permeable = permeable;
}

public boolean isFix() {
	return fix;
}

public void setFix(boolean fix) {
	this.fix = fix;
}

public boolean isIsolating() {
	return isolating;
}

public void setIsolating(boolean isolating) {
	this.isolating = isolating;
}

public boolean isSupporting() {
	return supporting;
}

public void setSupporting(boolean supporting) {
	this.supporting = supporting;
}

public boolean isHelper() {
	
	return helper;
}

public void setHelper(boolean helper) {
	this.helper = helper;
}
}
